﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class CampusDynamic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        NewsDataClassesDataContext dc = new NewsDataClassesDataContext();
        var Catalogs = from catalog in dc.Catalogs
                       where catalog.Catalog_id.Equals(5)
                       select new
                       {
                           Catalog_id = catalog.Catalog_id,
                           Name = catalog.CatalogName
                       };
        foreach (var catalog in Catalogs)
        {
            ListHyperLink.Text = catalog.Name + "列表";
            ListHyperLink.NavigateUrl = "CampusDynamicList.aspx";
            titleHyperLink.Text = catalog.Name;
        }

        int News_id = Convert.ToInt32(Session["News_id"]); 
        var News = from news in dc.News 
                   join postUser in dc.UserInfos
                   on news.Editor equals postUser.User_id
                   join checkUser in dc.UserInfos
                   on news.Checker equals checkUser.User_id

                   where news.News_id.Equals(News_id) && news.isPublished.Equals(1)
                   select new
                   {
                       标题 = news.Title,
                       内容 = news.Content,
                       发稿用户 = postUser.UserName,
                       审稿用户 = checkUser.UserName
                   };

        foreach (var news in News)
        {
            News_Title.Text = Convert.ToString(news.标题);
            News_Content.Text = Convert.ToString(news.内容);
            News_Content.Text += "<p>发稿用户 : " + Convert.ToString(news.发稿用户);
            News_Content.Text += "  审稿用户 : " + Convert.ToString(news.审稿用户) + "</p>";
        }
        dc.Dispose();
    }
}
